package com.enjoy.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class OrderController {
    @RequestMapping("queryOrder")
    @HystrixCommand(fallbackMethod = "list", commandProperties = {@HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "1")})
    public ResponseEntity<String> queryOrder() {
        log.info("查到用户订单了------");

        return ResponseEntity.ok("success");
    }

    public ResponseEntity<String> list() {
        System.out.println("进入list方法");
        return ResponseEntity.status(500).build();
    }
}
